#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2018, Niklas Hauser
# Copyright (c) 2017, Fabian Greif
# Copyright (c) 2020, Sascha Schade
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

class Amnb(Module):
    def init(self, module):
        module.name = "amnb"
        module.description = "Tests for AMNB"

    def prepare(self, module, options):
        module.depends("modm:communication:amnb", ":mock:clock", ":mock:shared_medium")
        return True

    def build(self, env):
        env.outbasepath = "modm-test/src/modm-test/communication"
        env.copy("amnb/message_test.cpp")
        env.copy("amnb/message_test.hpp")
        if not env.get("modm:processing:protothread:use_fiber", True):
            env.copy("amnb/interface_test.cpp")
            env.copy("amnb/interface_test.hpp")
            env.copy("amnb/node_test.cpp")
            env.copy("amnb/node_test.hpp")


class Sab(Module):
    def init(self, module):
        module.name = "sab"
        module.description = "Tests for SAB"

    def prepare(self, module, options):
        module.depends("modm:communication:sab", ":mock:io.device")
        return True

    def build(self, env):
        env.outbasepath = "modm-test/src/modm-test/communication"
        env.copy("sab")


class Xpcc(Module):
    def init(self, module):
        module.name = "xpcc"
        module.description = "Tests for XPCC"

    def prepare(self, module, options):
        module.depends(
            "modm:communication:xpcc",
            ":mock:clock",
            ":mock:can_driver",
        )
        return True

    def build(self, env):
        env.outbasepath = "modm-test/src/modm-test/communication"
        env.copy("xpcc")


def init(module):
    module.name = ":test:communication"
    module.description = "Tests for Communication Protocols"

def prepare(module, options):
    module.add_submodule(Amnb())
    module.add_submodule(Sab())
    module.add_submodule(Xpcc())
    return True

def build(env):
    pass
